export default {
	methods: {
		fmtProductFields(p) {
			let key = this.currProductKey
			let titleField = ''
			let coverField = 'cover'
			let priceField = 'price'
			//因为各个实体类的标题字段不一样，所以需要处理
			if (['XSK', 'GW', 'FW', 'NX', 'ZJ'].includes(key)) {
				titleField = 'name'
			} else if (['CP'].includes(key)) {
				titleField = 'title'
				priceField = 'promotionPrice'
			} else if (['XXK'].includes(key))
				titleField = 'courseName'
			else if (['ZB'].includes(key)) {
				titleField = 'roomName'
				priceField = 'presentPrice'
			}

			if ('ZJ' === key)
				coverField = 'headImg'

			let {
				detailPagePath
			} = this.productKVList.find(r => r.key === key)

			let params = {
				id: p.id
			}
			if (key === 'XXK') {
				params.id = p.offCourseId
				params.sch_id = p.id
			}
			
			return {
				avatar: p[coverField],
				title: p[titleField],
				price: p.free ? 0 : (p[priceField] || 0),
				oprice: p.originalPrice,
				url: this.makeUrl(detailPagePath, params),
			}

		},
	}
}
